package com.hxh.learn.controller;

import com.hxh.learn.model.Payment;
import com.hxh.learn.service.impl.PaymentServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.server.PathParam;
import java.util.Optional;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author hxh
 * @since 2023-02-28
 */
@RestController
@RequestMapping("/learn/payment")
@Api(tags = "测试相关")
public class PaymentController {
    @Autowired
    private PaymentServiceImpl paymentService;

    @GetMapping("/getUser")
    @ApiOperation("测试")
    public Payment getUser(@RequestParam String userId) {
        Payment payment = paymentService.getById(userId);
        Optional.ofNullable(payment).orElseThrow(() -> new RuntimeException("查询失败"));
        return payment;
    }

    @GetMapping("/getPermissions")
    @ApiOperation("测试")
    public String getPermissions() {
        return "get";
    }

    @GetMapping("/addPermissions")
    @ApiOperation("测试")
    public String addPermissions() {
        return "add";
    }

    @GetMapping("/updatePermissions")
    @ApiOperation("测试")
    public String updatePermissions() {
        return "update";
    }


}
